﻿using System.Collections;
using System.Collections.Generic;
using System.Text;
using TMPro;
using UnityEngine;

namespace Gamekit2D
{
    public class InputDisplayUI : MonoBehaviour
    {
        private void OnEnable()
        {
            TextMeshProUGUI textUI = GetComponent<TextMeshProUGUI>();
            if (PlayerInput.Instance == null)
            {
                textUI.SetText("## ERROR ## No PlayerInput detected");
                return;
            }

            StringBuilder builder = new StringBuilder();

            //builder.AppendFormat("{0} - Move Left\n", PlayerInput.Instance.Horizontal.negative.ToString());
            //builder.AppendFormat("{0} - Move Right\n", PlayerInput.Instance.Horizontal.positive.ToString());
            //builder.AppendFormat("{0} - Look Up\n", PlayerInput.Instance.Vertical.positive.ToString());
            //builder.AppendFormat("{0} - Crouch\n", PlayerInput.Instance.Vertical.negative.ToString());
            //builder.AppendFormat("{0} - Jump\n", PlayerInput.Instance.Jump.key.ToString());
            //builder.AppendFormat("{0} - Fire range weapon\n", PlayerInput.Instance.RangedAttack.key.ToString());
            //builder.AppendFormat("{0} - Melee Attack\n", PlayerInput.Instance.MeleeAttack.key.ToString());
            //builder.AppendFormat("{0} - Pause Menu\n", PlayerInput.Instance.Pause.key.ToString());

            //builder.AppendFormat("{0} - 向左移动\n", PlayerInput.Instance.Horizontal.negative.ToString());
            //builder.AppendFormat("{0} - 向右移动\n", PlayerInput.Instance.Horizontal.positive.ToString());
            //builder.AppendFormat("{0} - 向上看\n", PlayerInput.Instance.Vertical.positive.ToString());
            //builder.AppendFormat("{0} - 蹲下\n", PlayerInput.Instance.Vertical.negative.ToString());
            //builder.AppendFormat("{0} - 跳跃\n", PlayerInput.Instance.Jump.key.ToString());
            //builder.AppendFormat("{0} - 远程攻击\n", PlayerInput.Instance.RangedAttack.key.ToString());
            //builder.AppendFormat("{0} - 近身攻击\n", PlayerInput.Instance.MeleeAttack.key.ToString());
            //builder.AppendFormat("{0} - 暂停\n", PlayerInput.Instance.Pause.key.ToString());

            builder.AppendFormat("摇杆往左拖动 - 向左移动\n");
            builder.AppendFormat("摇杆往右拖动 - 向右移动\n");
            builder.AppendFormat("摇杆往上拖动 - 向上看\n");
            builder.AppendFormat("摇杆往下拖动 - 向下看 / 往下跳跃\n");
            builder.AppendFormat("右一按钮 - 跳跃\n");
            builder.AppendFormat("右二按钮 - 近战攻击\n");
            builder.AppendFormat("右三按钮 - 远程攻击\n");
            builder.AppendFormat("右四按钮 - 暂停\n");

            textUI.SetText(builder);
        }
    }
}